package cn.it.shop.service.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.classic.Session;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.stereotype.Service;

import cn.it.shop.pojo.Privilege;
import cn.it.shop.pojo.Role;
import cn.it.shop.service.PrivilegeService;
import cn.it.shop.service.RoleService;

@Service("privilegeService")
@SuppressWarnings("unchecked")
public class PrivilegeServiceImpl extends BaseServiceImpl<Privilege> implements
		PrivilegeService, FilterInvocationSecurityMetadataSource {

	@Override
	public List<Privilege> queryForTree() {
		return privilegeDao.queryForTree();
	}

	@Override
	public String[] getPrivilegeURL(Set<Privilege> privilegeSet) {
		String[] myUrl = new String[privilegeSet.size()];
		int num = 0;
		for (Privilege temp : privilegeSet) {
			myUrl[num++] = temp.getUrl();
		}
		return myUrl;
	}

	@Override
	public Collection<ConfigAttribute> getAttributes(Object object)
			throws IllegalArgumentException {
		return privilegeDao.getAttributes(object);
	}

	@Override
	public Collection<ConfigAttribute> getAllConfigAttributes() {
		return privilegeDao.getAllConfigAttributes();
	}

	@Override
	public boolean supports(Class<?> clazz) {
		return true;
	}

}
